
//import java.sql.*;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;


public class ReadData{
    public static void main( String args[] ){
      
	try {
	    System.out.println("Connection.........");
	    Class.forName("org.sqlite.JDBC");
	    System.out.println("Driver: OK");
	    Connection c = DriverManager.getConnection("jdbc:sqlite:test.sqlite");
	    System.out.println("DB: OK");
	    c.setAutoCommit(true);

	    Statement stmt = null;
	    stmt = c.createStatement();
	    
	    //String sql1 = "Drop table Truck";
	    
	    String sql = "CREATE TABLE IF NOT EXISTS TRUCK " +
		"(ID INT PRIMARY KEY  UNIQUE   NOT NULL," +
		" NAME            TEXT    NOT NULL, " + 
		" WEIGHT          INT     NOT NULL, " + 
		" MP              FLOAT, " + 
		" SALARY          FLOAT)"; 
	    stmt.executeUpdate(sql);


	    stmt.executeUpdate("INSERT INTO TRUCK(ID, NAME, WEIGHT, MP)"
			       +"VALUES('777', 'AA', 7, 18);");
	    
	    
	    ResultSet rs = stmt.executeQuery("SELECT * FROM TRUCK;");
	    System.out.println(rs.getInt("id"));
	    stmt.close();
	    
	    
	    /*
	    xecuteUpdate("CREATE TABLE IF NOT EXISTS "
	      + DBTaskDAO.TABLE_NAME
	      + " ("
	      + DBTaskDAO.CREATE_TABLE_STATEMENT + ")");
	      executeUpdate("CREATE TABLE IF NOT EXISTS "
	      + DBUserDAO.TABLE_NAME
	      + " ("
	      + DBUserDAO.CREATE_TABLE_STATEMENT + ")");
	    */
	    c.close();
	} catch ( Exception e ) {
	    System.err.println( e.getClass().getName() + ": " + e.getMessage() );
	    System.exit(0);
	    /*    } catch (ClassNotFoundException e) {
		  System.err.println( e.getClass().getName() + ": " + e.getMessage() );
		  System.exit(0);*/
	}
	
	System.out.println("Opened database successfully");
    }
}


